﻿using System;
using System.Linq;

using TempEmployees.DAL;

namespace TempEmployees.BLL.Database
{
    public static class DbConstants
    {
        [Flags]
        public enum Roles : int
        {
            None = 0,
            Secretary = 1,
            HeadDepartment = 2,
            Employer = 4,
            SystemAdmin = 8,
            Accountant = 16
        }

        public enum Status
        {
            Active = 1,
            Approved = 2,
            Pending = 3,
            Rejected = 4,
            Finished = 5
        }

        public enum BudgetType
        {
            Mosadi = 1,
            Technioni = 2
        }
    }

    /// <remarks>
    /// extension clas Roles enum
    /// </remarks>
    public static class ConstExt
    {
        /// <summary>
        /// gives the hebrew name of the role
        /// </summary>
        /// <param name="num">instance of the calling varaiable</param>
        /// <returns>hebrew name of the role</returns>
        public static string HebrewName(this DbConstants.Roles role)
        {
            Role r = DbQuery.GetSingleRow<Role>("ID", (int)role);
            return (r != null) ? r.Name : "ריק";
        }

        public static string HebrewName(this DbConstants.BudgetType budgetType)
        {

            return DbQuery.GetSingleRow<BudgetType>("ID", (int)budgetType).Name.Trim();
        }
    }
}
